package com.restfinder.common.component;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.net.URL;
import java.util.Properties;

import com.restfinder.user.service.UserService;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class PropertiesUtils {
	
	private static final String FILE_NAME_PROPERTIES	= "restfinder.properties";
	
	public static String getPropertyValue(String key, String defaultValue){
		return loadJavaUtilProperties(FILE_NAME_PROPERTIES).getProperty(key, defaultValue);
    }

    private static Properties loadJavaUtilProperties(String name) {
		try {
			ClassLoader loader = UserService.class.getClassLoader();
			Properties properties = new Properties();
			properties.load(loader.getResourceAsStream(name));
			return properties;
		} catch (Exception e) {
			log.error("Exception while loading properties file",e);
		}
		return null;
	}
}
